package com.xrj4j.controller.api;


import com.xrj4j.common.ResponseResult;
import com.xrj4j.service.SponsorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;

@RequestMapping("/v1/sponsor")
@RestController
@Api(tags = "打赏接口")
@RequiredArgsConstructor
public class ApiSponsorController {

    private final SponsorService sponsorService;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String callBack(String orderId, Double price, Double reallyPrice) {
        return sponsorService.callBack(orderId, price, reallyPrice);
    }

    @RequestMapping(value = "createOrder", method = RequestMethod.GET)
    public ResponseResult createOrder(BigDecimal price, int payType) throws NoSuchAlgorithmException {
        return sponsorService.createOrder(price, payType);
    }

    @ApiOperation(value = "打赏记录列表", httpMethod = "GET", response = ResponseResult.class, notes = "打赏记录列表")
    @GetMapping("list")
    public ResponseResult selectSponsorList() throws NoSuchAlgorithmException {
        return sponsorService.selectSponsorList();
    }
}
